import { map, upperCase } from 'lodash';

/**
 * 授权 Action
 * `ctx.query.redirect` should be URL-encoded
 * @param  {Context} ctx
 * @return {Object}
 */
export async function authorizationAction(ctx) {
    // 失败
    //let errCode = 9901;
    // return ctx.redirect(`${ctx.query.redirect}#!/auth?err=${errCode}&t=${ctx.query.t}`);

    // 成功
    return ctx.redirect(`${ctx.query.redirect}#!/auth?token=kljxGc5w&t=${ctx.query.t}`);
}

/**
 * 自定义报错 Action
 * @param  {Context} ctx
 * @return {Object}
 */
export async function actionWithException(ctx) {
    ctx.set('ErrorCode', Number(2000004));

    ctx.body = {
        mess: 'This is a custom error message'
    };
}
